<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        // sum(10)  = sum(9) + 10
        // sum(9) = sum(8) + 9 
        // sum(8) = sum(7) + 8
        // ...
        // sum(2) = sum(1) + 2 
        // sum(1) = 1 ;


        function sum(n) {
            if (n === 1) {
                return 1
            }
            return sum(n - 1) + n;
        }

        document.write(sum(10))







    </script>

</body>

</html>